//
//  DDTagTextVC.m
//  dingdang
//
//  Created by 阮 沧晖 on 15/7/13.
//  Copyright (c) 2015年 阮 沧晖. All rights reserved.
//

#import "DDTagTextVC.h"

@interface DDTagTextVC ()


@end

@implementation DDTagTextVC

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        
        _textTF = [[UITextField alloc] initWithFrame:CGRectMake(0, 64, [UIScreen mainScreen].bounds.size.width, 44)];
        _textTF.placeholder = @"请输入标签内容";
        _textTF.backgroundColor = [UIColor whiteColor];
        [self.view addSubview:_textTF];
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    [self createUI];
    [self createData];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)createUI
{
    self.view.backgroundColor = RGB(245, 245, 245);
    self.automaticallyAdjustsScrollViewInsets = NO;
    self.navigationController.navigationBarHidden = YES;
    //自定义TAB BAR UI
    DDTagTextVC *weakSelf = self;
    [self addNavigatorTitle:NSLocalizedString(self.title, nil) parent:self.view];
    self.barViewControl.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"top_Background"]];
    [self AddLeftBtnAction:nil normal:@"top_返回" selected:@"top_返回" action:^{
        [weakSelf dismissViewControllerAnimated:YES completion:nil];
        [weakSelf.navigationController popViewControllerAnimated:YES];
    }];
    if (!_isNonDisplay) {
        [self AddRightBtnAction:@"完成" normal:nil selected:nil action:^{
            if ([weakSelf.textTF.text isEqualToString:@""]) {
                UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"提示" message:@"请输入标签内容" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles: nil];
                [alertView show];
                return ;
            }
            if (weakSelf.reslutText) {
                weakSelf.reslutText(weakSelf.textTF.text);
            }
        }];
    }
    
    
//    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 64, self.view.frame.size.width, 44)];
//    
//    [self.view addSubview:label];
}

-(void)setTextResult:(NSString *)text
{
     _textTF.text = text == nil ? @"":text;
}
@end
